package com.yangyang.ralearn.message;

import java.util.List;

import org.jboss.netty.channel.Channel;

import com.yangyang.ralearn.common.entity.base.AbstractDomainPredicate;
import com.yangyang.ralearn.net.message.AbstractReqMessage;
import com.yangyang.ralearn.net.message.Message;
import com.yangyang.ralearn.net.message.MessageFactory;
import com.yangyang.ralearn.net.message.MessageId;
import com.yangyang.ralearn.server.ServerManager;
import com.yangyang.ralearn.util.Object2String;

@Message(id = MessageId.REQ_OBSERVE)
public class ReqObserveMessage extends AbstractReqMessage {

	@Override
	public void onGetClientMessage(int groupId, int simulatorId, Channel channel) {
		// TODO Auto-generated method stub
		List<AbstractDomainPredicate> list = ServerManager.instance()
				.getSimulatorById(groupId, simulatorId).observe();
		RespObserveMessage message = (RespObserveMessage) MessageFactory
				.instance().createMessage(
						MessageId.encodeId(MessageId.RESP_OBSERVE, groupId,
								simulatorId));
		message.init(new Object2String<List<AbstractDomainPredicate>>()
				.object2String(list));
		ServerManager.instance()
				.sendMessage(groupId, message, (Integer[]) null);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
